Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Subject of the issue
Corrupted display, specifically clear is not working. I have traced to the OLED controller (SSD1306) is not handling the I2C restart bit properly.
Your workbench
Steps to reproduce
Expected behavior
The display should properly display the splash screen and following screens.
Actual behavior
The screen did not get cleared. Garbage is being displayed around the edges of the splash screen.
Garbage is displayed around the edges of the main Rover screen.
The Change
With the restart bit, the OLED controller seems to ignore write data prior to the final restart bit. A few bits seem to be written and the rest of the display is left with its previous results. This causes the clear operation which uses the restart bit to fail to clear the display RAM. Other large writes also fail when the restart bit is sent.
This change removes the use of the I2C restart bit and sends a stop bit instead. The OLED controller (SSD1306) seems to be remembering where the data should be placed and continues the writing the next data segment to display RAM properly. As such, the clear operation is broken into sever I2C transfers each bounded by a start and stop bit. Transmitting the data segments with the start and stop bits causes the OLED controller to properly clear the display RAM.
Where is the Issue?
Limited testing indicates the is the OLED controller's (SSD1306) handling of the I2C restart bit. The GNSS library is using the I2C restart bit in communications with the GPS. Removing the use of the restart bit for that library, causes the GNSS library to fail all communications with the GPS. As such, the ESP32 must be sending the restart bit successfully and the GPS must be receiving it successfully and processing it accordingly.
What can break?
If the ESP32 is being used in a multi-master design, then not using the restart allows another bus master to potentially slip something between the two segments of the transfer. This would delay the transmission of the next segment of data. If two or more masters were writing to the OLED display then not using the restart opens up a window where another master could send a command to the SSD1306 and change the current column or page. This would cause the subsequent portion of data to be placed in the wrong location and possibly write past the end of display memory.
As long as a single master is on the I2C bus, I2C timing changes slightly due to the addition of the stop bit, but no other impact to the devices in the I2C bus should be seen.